package com.amigo.online.provider.msync.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.amigo.online.common.base.controller.BaseController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.common.core.security.IgnoreSecurity;
import com.amigo.online.provider.common.util.BasicUtil;
import com.amigo.online.provider.msync.service.MusicSyncService;
import com.amigo.online.provider.msync.service.UserSyncService;
import com.amigo.online.provider.msync.service.VideoSyncService;

@RestController
@RequestMapping(value = "/v1/manual/sync", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class ManualSyncDataV1Controller extends BaseController {

    @Autowired
    UserSyncService userSyncService;

    @Autowired
    VideoSyncService videoSyncService;

    @Autowired
    MusicSyncService musicSyncService;

    @IgnoreSecurity
    @PostMapping(value = "/private/admin/sync/mongo/user")
    public ResponseEntity<Response> comparisonUserFromMysqlToMongo(@RequestBody String ids) {
        return success(userSyncService.comparisonUserFromMysqlToMongo(BasicUtil.convertStringIdsToList(ids, ",")));
    }

    @IgnoreSecurity
    @PostMapping(value = "/private/admin/sync/solr/user")
    public ResponseEntity<Response> comparisonUserFromMysqlToSolr(@RequestBody String ids) {
        return success(userSyncService.comparisonUserFromMysqlToSolr(BasicUtil.convertStringIdsToList(ids, ",")));
    }

    @IgnoreSecurity
    @PostMapping(value = "/private/admin/sync/mongo/video")
    public ResponseEntity<Response> comparisonVideoFromMysqlToMongo(@RequestBody String ids) {
        return success(videoSyncService.comparisonVideoFromMysqlToMongo(BasicUtil.convertStringIdsToList(ids, ",")));
    }

    @IgnoreSecurity
    @PostMapping(value = "/private/admin/sync/solr/video")
    public ResponseEntity<Response> comparisonVideoFromMysqlToSolr(@RequestBody String ids) {
        return success(videoSyncService.comparisonVideoFromMysqlToSolr(BasicUtil.convertStringIdsToList(ids, ",")));
    }

    @IgnoreSecurity
    @PostMapping(value = "/private/admin/sync/mongo/music")
    public ResponseEntity<Response> comparisonMusicFromMysqlToMongo(@RequestBody String ids) {
        return null;
    }

    @IgnoreSecurity
    @PostMapping(value = "/private/admin/sync/solr/music")
    public ResponseEntity<Response> comparisonMusicFromMysqlToSolr(@RequestBody String ids) {
        return success(musicSyncService.comparisonMusicFromMysqlToSolr(BasicUtil.convertStringIdsToList(ids, ",")));
    }


}
